package com.dms.service;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;
import com.dms.dao.*;
import com.dms.model.Domitory;
@Service
public class DomitoryService {
	@Resource
	private DomitoryDao dao;
	
	public Domitory getDomitory(int id){
		String hql="from Domitory where id="+id;
		return dao.getDomitory(hql);
	}
	
	public void updateDomitory(Domitory domitory) {
		dao.updateDomitory(domitory);
	}
	
	public List<Domitory> getDomitoryList(){
		String hql="from Domitory";
		return dao.getDomitorys(hql);
	}
	
	public List<Domitory> searchDomitory(String bId,String name){
		String hql="from Domitory where building.id="+bId+
			" and name='"+name+"'";
//		System.out.println("searchDomitory hql="+hql);
		return dao.getDomitorys(hql);
	}
	
	public void saveDomitory(Domitory domitory){
		dao.save(domitory);
	}
	
	public void deleteDomitory(int id){
		dao.delete(id);
	}
	
}
